home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 037a / pavt110.zip / PAVATAR1.DOC < prev    next >
Text File  |  1991-09-07  |  20KB  |  478 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.                            PAvatar 1.10
  14.                        Preliminary Release
  15.              Turbo Pascal Avatar Level 1 Console Kit
  16.                  Copyright 1991 Gregory P. Smith
  17.  
  18.  
  19. Part I.  Introduction
  20. ──────────────────────────────────────────────────────────────
  21.  
  22.     This toolkit represents hundreds of hours of programming 
  23.     that resulted in this fast and accurate product.  PAvatar is a 
  24.     Turbo Pascal unit (version 5.5 or later) that can provide your 
  25.     programs with Avatar level 1 console, extended Avatar level 0+ 
  26.     (optional ANSI fallback), ANSI-BBS, and ANSI terminal 
  27.     emulations.  This is done with a series of procedural hooks 
  28.     for screen I/O and cursor control.  This allows you to use the 
  29.     procedures of your choice, making the unit the most flexible 
  30.     of its type.
  31.     An added bonus to using this unit is DESQview awareness.  
  32.     This unit contains facilities for detecting DESQview, giving 
  33.     up the time slice, and using DESQview's video buffer.  This is 
  34.     especially valuable for communications and bbs type programs 
  35.     that are often run under DESQview.
  36.  
  37.  
  38. Requirements
  39. ─────────────────────────────
  40.  
  41.         This unit requires that you are using an IBM compatible 
  42.     computer and have Turbo Pascal 5.5 or later.  As I have used 
  43.     OOP for fast and efficient data management within this unit; I 
  44.     regret that I cannot provide a Turbo Pascal 5.0 version of the 
  45.     PAvt1 unit.
  46.         Memory requirements within a program using PAvatar have 
  47.     been kept to a minimum.  Only 3-4k of heap space as well as 
  48.     less than 500 bytes stack space.  The actual code itself only 
  49.     requires 16k.
  50.  
  51.  
  52. Shareware
  53. ─────────────────────────────
  54.  
  55.         I am distributing this unit under a relaxed shareware 
  56.     concept so as to promote Avatar.  You are free to use the 
  57.     compiled unit however you want, as long as I'm given credit 
  58.     for the terminal emulations somewhere in the documentation or 
  59.     in the program itself.  Please let me know of any programs 
  60.     that you write using PAvatar so that I can recommend them to 
  61.     others.
  62.         If you want the source code to this unit it is available 
  63.     for $10 U.S., see the registration form for details.  The 
  64.     possible benefits of having source code are described later in 
  65.     this document.
  66.  
  67. Liability
  68. ─────────────────────────────
  69.  
  70.         To use PAvatar you must first agree that I cannot be held 
  71.     responsible for any damages or problems that occur from its 
  72.     use or misuse.  If you do not agree to these terms don't use 
  73.     this unit.
  74.  
  75.  
  76. Part II.  QUICK START
  77. ──────────────────────────────────────────────────────────────
  78.  
  79.         First off you must install your unit.  To do so, copy the 
  80.     appropriate TPU file into your units directory (the TPU's have 
  81.     been renamed to .T55 for TP 5.5 and .T60 for TP 6.0, you must 
  82.     rename yours).  Next, copy the demo program A1DEMO.PAS into 
  83.     your pascal directory.  Type TPC a1demo or compile it to disk 
  84.     from the IDE.  You now have a utility for displaying AVT/1, 
  85.     AVT/0+, and ANSI files that is DESQview aware.  Unless you're 
  86.     a Sysop, you probably don't have lots of .AVT Avatar files.  
  87.     Currently there is no Avatar editor, but you may use my ANSI 
  88.     to Avatar/0+ converter to create Avatar files.  It's found on 
  89.     BBS's as A2AVTnnn.ZIP where nnn is the version number 
  90.     (currently 2.10).  When typing level 0 files, be sure to use 
  91.     the /PLUS parameter to indicate that it is not a level 1 file 
  92.     (The differences are described later).
  93.  
  94. Part III.  Interface
  95. ──────────────────────────────────────────────────────────────
  96.  
  97. Procedures
  98. ─────────────────────────────
  99.  
  100.         PAvatar is a self sufficient unit in that only two 
  101.     procedures are required to add an Avatar or ANSI terminal to 
  102.     your program.  However, there are more than two procedures 
  103.     available so that you can take advantage of many special 
  104.     features of the unit.  The procedures and definitions follow.
  105.  
  106. Procedure Parse_AVT1 (ch:char);
  107.  
  108.              This is the main procedure of the unit.  It takes 
  109.          character ch and parses it according to the status.  For 
  110.          instance if you pass it a ^V it would go into the Avatar 
  111.          command mode in which the next character would represent 
  112.          an Avatar command.  If it were an Esc and ANSI was 
  113.          enabled, the next character passed to it would  be tested 
  114.          for a bracket '[' or a shorter VT52 style ANSI  commands.  
  115.          This is the heart of the whole unit.
  116.  
  117. Procedure ResetTerminal (nc,nl:byte);
  118.  
  119.              This procedure is used to Reset the Terminal 
  120.          emulation with screen dimensions nc columns and nl lines.  
  121.          It always takes you back to the original mode with AVT/1 
  122.          active, and ANSI fallback turned off.  It has the same 
  123.          effect as issuing a ^V^R to the AVT/1 parser.
  124.  
  125. Procedure SetScreen(nc,nl:byte);
  126.  
  127.              Use this procedure when you want to change the size 
  128.          of the terminal screen without resetting everything else 
  129.          as in the ResetTerminal procedure.  The only thing this 
  130.          does is re-define all of the Avatar windows to have nc 
  131.          columns and nl lines.
  132.  
  133. Procedure AvtInterp (ch:char);
  134.  
  135.              This procedure is called by the Parser to interpret 
  136.          the Avatar codes after DLE's and special considerations 
  137.          have been processed.  When in ANSI_Only or AVT/0+ mode 
  138.          you can use this instead of Parse_AVT1.  The extra 
  139.          overhead of Parse_AVT1 is so small that using this is 
  140.          usually not worth it.
  141.  
  142. Procedure AvtTTY (ch:char);
  143.  
  144.              This procedure is called by the AVT/1 Parser when a 
  145.          character is not part of a control code.  It simply 
  146.          writes character ch to the screen following the current 
  147.          Avatar window setup (including flow, insert, direction, 
  148.          etc..).  The only characters that it processes are CR, 
  149.          LF, BS, Tab, and Bell.  You should not need this 
  150.          procedure, but it's here if you do.
  151.  
  152. Procedure Level0_Simulation (fallbck:boolean);
  153.  
  154.              This procedure places the interpreter into an 
  155.          extended AVT/0+ emulation mode.  If fallbck is true ANSI 
  156.          fallback will be on.  Internally, this procedure re- 
  157.          configures AVT/1's window 0 to have a default color of 
  158.          cyan (3), as well as turning cooked mode off.  Using this 
  159.          procedure is more effective than sending the equivalent 
  160.          codes for defining a level 0 simulation in a certain 
  161.          window.  Destructive backspaces are also disabled.
  162.  
  163. Procedure ANSI_Only;
  164.  
  165.              Use this procedure when you want to place the 
  166.          parser in ANSI Only mode.  It is the equivalent of 
  167.          putting the AVT/1 parser to sleep and disabling fallback.  
  168.          This is faster than fallback mode.
  169.  
  170. Procedure AvtSound (note:byte; oct:shortint; dur:byte);
  171.  
  172.              This procedure is a shortcut to stuff music into 
  173.          the Avatar sound buffer without having to send the code 
  174.          to the parser.  Note represents the musical note in the 
  175.          same method which AVT/1's ^V^S command uses it.  That is 
  176.          note is equal to (tone - 'A') * 2 + sharp where tone is 
  177.          somewhere between 'A' and 'G'.  Sharp is a 0 or a 1 as 
  178.          the case may be.  A pause is generated by a note of 14 or 
  179.          greater.  The octave is a signed integer in oct where 0 
  180.          represents middle octave and 1 the next highest, -1 the 
  181.          next lowest.  Dur is the duration in tenths of a second.  
  182.          If two identical notes are queued in a row, they will be 
  183.          played legato so that they run together.
  184.  
  185. Procedure StuffSound (frq,dur:integer);
  186.  
  187.              This procedure is called by the above procedure.  
  188.          It is used to place a sound of frq hertz and dur tenths 
  189.          of a second into the Sound buffer.  If the buffer is 
  190.          full, it will wait until space is available.
  191.  
  192. Function DESQview_version: word;
  193.  
  194.              This is the first of the DESQview supportive 
  195.          routines in this unit.  The DESQview major version number 
  196.          is in the high byte, while the minor version is in the 
  197.          low byte.  A zero is returned if DESQview is not loaded.
  198.  
  199. Procedure DV_Pause;
  200.  
  201.              This procedure will give up the current time slice 
  202.          if you are in DESQview.  It does nothing otherwise.  Use 
  203.          this procedure when your program is not doing anything, 
  204.          to give the other programs more processing time.  Do not 
  205.          hesitate to use this procedure, it's written in assembler 
  206.          so that it's execution time isn't even measurable.
  207.  
  208. Function ReadKey: char;
  209.  
  210.              This is a replacement for the Crt unit's ReadKey 
  211.          that gives up the current DESQview time slice (via 
  212.          DV_Pause) if a key hasn't been pressed.  
  213.  
  214. Procedure SwapVectors;
  215.  
  216.              If you plan on shelling to DOS or swapping portions 
  217.          of your program out, this is a must.  As Avatar uses 
  218.          background sound, the unit hooks into interrupt $1C.  
  219.          This is an extension of the DOS unit's SwapVectors which 
  220.          also restores interrupt $1C.
  221.  
  222. Variables
  223. ─────────────────────────────
  224.  
  225.     There are only a few non-procedural variables that you can 
  226.     use to check or modify the status of the terminal.  They are 
  227.     all static variables with defined defaults.
  228.  
  229. ANSI_BBS : boolean = False;
  230.  
  231.              Use this variable to decide whether the ANSI 
  232.          portion of the unit will use the "BBS" style.  The only 
  233.          differences when this is true are that Esc[2J also homes 
  234.          the cursor and Esc[J acts the same as Esc[2J instead of 
  235.          Esc[0J.  DOS's own ANSI.SYS is infamous for processing 
  236.          Esc[2J this way.
  237.  
  238. Fallback : boolean = False;
  239.  
  240.              This variable controls whether ANSI fallback will 
  241.          be on during Avatar emulations.  It is best not to mess 
  242.          with this variable when using AVT/1 as it is designed 
  243.          primarily for use with AVT/0+.
  244.  
  245. ScrnLines : byte = 25;
  246.  
  247.              This variable simply defines the number of lines 
  248.          that you want on your terminal screen.  Modifying this 
  249.          variable can produce strange results.  It is recommended 
  250.          that you use the Terminal Reset procedure to define the 
  251.          screen size.
  252.  
  253. ScrnColumns : byte = 80;
  254.  
  255.              This variable is the partner of the above one.  It 
  256.          defines the number of columns you want on your terminal 
  257.          screen.  The same restrictions apply with this variable 
  258.          as on the above.
  259.  
  260. QueryReply : string[80] = 'AVT1, Avatar/1 Console Copr.  1991 Greg Smith. Ver 1.10'+^M;
  261.  
  262.              When the Avatar terminal id request is received 
  263.          this is the string that will be returned.  The "AVT1," at 
  264.          the beginning is important to the remote terminal.  It is 
  265.          used to define the capabilities of the terminal.  
  266.          Everything else is just your own logo or program ID.  In 
  267.          level 0+ simulation mode the AVT1 is changed to AVT0.
  268.  
  269. Dest_BS : boolean = True;
  270.  
  271.              As the name implies, this variable controls the 
  272.          behavior of the backspace (^H) character.  The AVT/1 
  273.          specifications require a Destructive backspace while the 
  274.          AVT/0 specifications require that it is non-destructive.
  275.  
  276. Constants
  277. .
  278.  
  279.     The following constants are available for general use.
  280.  
  281.              Esc = ^[;
  282.              DLE = ^P;
  283.              FS = #28;
  284.              GS = #29;
  285.              RS = #30;
  286.              US = #31;
  287.              SP = #32; { space }
  288.  
  289.  
  290. User Hooks
  291. ─────────────────────────────
  292.  
  293.         The interface for this unit has been designed to be as 
  294.     flexible as possible without hindering the performance of the 
  295.     unit.  Besides the main procedures and a few variables most of 
  296.     it is procedural hooks.  Their definitions follow.
  297.  
  298. Query_Hook : ReplyProc = Procedure (S:String);
  299.  
  300.              This hook is used for all terminal queries or 
  301.          responses such as the Avatar driver query and the ANSI 
  302.          report cursor position.  Usually these replies will be 
  303.          placed in the keyboard buffer or sent out the comm port.  
  304.          In a1demo, the hook is left at its null procedure setting 
  305.          as there is no use for it in that type of utility.  Note 
  306.          that information passed to this hook should be inserted 
  307.          immediately into the input or output buffer so that it is 
  308.          the next thing to be processed if you wish to comply 
  309.          fully with the AVT/1 specifications.
  310.  
  311. WriteATh : WriteATHookT = Procedure (x,y,a:byte;ch:char);
  312.  
  313.              This hook is simple and important.  It should write 
  314.          character ch on the screen at location x,y using 
  315.          attribute a.  This is the only thing it should do, it 
  316.          should not mess with the cursor or scroll the screen.
  317.  
  318. GotoXYh : GotoXYHookT = Procedure (x,y:byte);
  319.  
  320.              This hook is used to set the cursor position.  
  321.          Often this routine will call the Crt unit's GotoXY 
  322.          procedure.  It is provided for flexibility and the 
  323.          possibility of using PAvatar in a virtual screen or 
  324.          window.  Full checking against ScrnLines and ScrnColumns 
  325.          is performed internally.
  326.  
  327. Scrollh : ScrollHookT = Procedure (dir,x1,y1,x2,y2,n,a:byte);
  328.  
  329.              This hook is important to Avatar's power.  It 
  330.          scrolls the screen region of (x1,y1)-(x2,y2) n lines in 
  331.          the direction indicated in dir (1=up, 2=down, 3=left, 
  332.          4=right).  The empty area created by the scroll should be 
  333.          filled with blank spaces of color attribute a.  Most 
  334.          decent windowing toolkits have a procedure suitable for 
  335.          this.
  336.  
  337. FillAreah : FillHookT = Procedure (x1,y1,x2,y2,a:byte;ch:char);
  338.  
  339.              This hook is used to fill the screen region of 
  340.          (x1,y1)- (x2,y2) with character ch in attribute a.  If 
  341.          your scrolling procedure doesn't support a fill color for 
  342.          the newly exposed area, this is a good procedure to use 
  343.          for it.
  344.  
  345. GetATh : GetCharHookT = Procedure (x,y:byte;var a:byte;var c:char);
  346.  
  347.              This hook is the opposite of the WriteATh hook in 
  348.          that its purpose it to retrieve information from the 
  349.          screen.  Variable parameters c and a should be set to the 
  350.          character and attribute at the coordinates of x,y 
  351.          respectively.
  352.  
  353. HighAreah : HighHookT = Procedure (x1,y1,x2,y2,a:byte);
  354.  
  355.              Similar to FillAreah, this hook fills an area of 
  356.          the screen.  The area defined by (x1,y1)-(x2,y2) should 
  357.          be filled with attribute a, but the characters on the 
  358.          screen should not be disturbed.
  359.  
  360. Pauseh : PauseHookT = Procedure (tenths:word);
  361.  
  362.              The only purpose of this hook is to allow for 
  363.          controlled system pauses.  This hook should pause the 
  364.          terminal for tenths tenths of a second.  The reason I 
  365.          didn't just use a delay(100) within the unit is for the 
  366.          protection of the user.  With avatar, codes could be sent 
  367.          that could conceivable pause the system for several days.  
  368.          It is up to you to add a method of breaking out of a 
  369.          pause such as a key press.
  370.  
  371. FlushInputh : Procedure;
  372.  
  373.              This hook has a default effect of zeroing the 
  374.          keyboard buffer.  If your program has any internal 
  375.          buffers or communications buffer, you may wish to flush 
  376.          them when this hook is called.  The Avatar flush input 
  377.          command calls this hook.
  378.  
  379. The PAvt0 Small Version
  380. ─────────────────────────────
  381.  
  382.         Now included with the Pavt package is a PAvt0 Small version 
  383.     of the unit.  This unit is an AVT/0+ and ANSI-BBS terminal 
  384.     only.  It is much faster that the AVT/1 unit as there are no 
  385.     flow and window controls.  The primary use for this unit is 
  386.     for BBS door programs which won't be using AVT/1.  Overall the 
  387.     code there is 10.5k less code and 650 bytes less data as well 
  388.     as a minimal heap usage.
  389.         The PAvt0 unit is designed as a drop in replacement for the 
  390.     PAvt1 unit.  However there are a few procedures and variables 
  391.     which don't exist in the PAvt0 unit.  The Pauseh and 
  392.     FlushInputh hooks are not available, the Level0_Simulation and 
  393.     Parse_AVT1 procedures are not available (AvtInterp should be 
  394.     used instead), and the ANSI_BBS variable is gone.  All of 
  395.     these were removed as they served no purpose in AVT/0+.  In 
  396.     addition, this unit parses tab characters (^I) as 8 spaces 
  397.     instead of the definable (defaults to 8 char tabs) tab stops 
  398.     of the full unit.
  399.  
  400.  
  401. Part IV.  Special Considerations
  402. ──────────────────────────────────────────────────────────────
  403.  
  404. Avatar 1 Console
  405. ─────────────────────────────
  406.  
  407.         The Avatar level one console is a very powerful terminal 
  408.     emulation.  Naturally it goes without saying that there are a 
  409.     few things that must be considered if you wish to comply with 
  410.     the full AVT/1 console specifications.  I've already mentioned 
  411.     the need to insert the query replies first into the input or 
  412.     output buffer.  Secondly, AVT/1 features a sleep mode for its 
  413.     interpreter, so ANSI fallback should not be used as a remote 
  414.     program using level 1 codes should know how to switch between 
  415.     sleeping (ANSI) and awake (AVT/1).
  416.         The main thing you should be concerned about in 
  417.     communications is flow control.  AVT/1 has a way to get around 
  418.     interference with XON/XOFF flow control if the parser is in 
  419.     cooked mode, but if it's switched to raw mode, the results 
  420.     will be disastrous.  As AVT/0+ is a raw only terminal, 
  421.     XON/XOFF must be disabled while it is active.
  422.  
  423.  
  424. Tips & Tricks
  425. ─────────────────────────────
  426.  
  427.         The AvtInterp procedure is actually a procedural variable 
  428.     that is passed a character as its only parameter.  This should 
  429.     let you know a lot about how PAvatar works internally, as well 
  430.     as add flexibility.  If you wish to add your own terminal, 
  431.     just assign your own procedures to AvtInterp.  This will work 
  432.     when you are calling AvtInterp directly instead of Parse_AVT1.  
  433.     Of course, remember to call the parser when you switch to 
  434.     AVT/1.
  435.         That is the only "hidden" feature I will expose right now, 
  436.     but expect more in upcoming versions.
  437.  
  438.  
  439. Part V.  History And Credits
  440. ──────────────────────────────────────────────────────────────
  441.  
  442.         I thank Ping Hansen in the FidoNet pascal echo and an 
  443.     unknown someone in the FidoNet communications echo for 
  444.     sparking my interest in terminal emulations and Avatar.  I 
  445.     also would like to thank G. Adam Stanislav for taking on the 
  446.     project of updating the Avatar specification past its original 
  447.     Opus level commands.  Last but not least, I would like to 
  448.     thank my parents for putting up with me being on the computer 
  449.     so many hours.
  450.  
  451. Release Sites
  452. ─────────────────────────────
  453.  
  454.         The following is a list of BBS's where you can find the 
  455.     latest version of PAvatar as well as contacting me.
  456.  
  457. (303)320-4078  CMOS BBS line 1,  300-9600, Fido: 1:104/441
  458. (303)322-4125  CMOS BBS line 2,  300-9600, Fido: 1:104/469
  459. (303)449-8946  Bohemia BBS Sys,  300-2400, Fido: 1:104/120
  460. (303)750-7136  Borealis WildCat, 1200-9600, RIME: ->BOREALIS
  461. (303)674-1305  Wizardry line 1, 1200-9600. Fido: 1:104/630
  462.  
  463. Mark Cook, Sysop of Wizardry, is my only beta tester at this time.  I will acquire more as I feel the need.
  464.  
  465.  
  466. ──────────────────────────────────────────────────────────────
  467.  
  468. Send all questions, comments, problems, ideas, money, etc.. to:
  469.  
  470.     Gregory P. Smith
  471.     4422 Pali Way
  472.     Boulder, CO. 80301 USA
  473.  
  474. Fidonet:  1:104/441,120,477,630
  475. RIME: ->BOREALIS
  476. UseNet/InterNet: gpsmith@bohemia.metronet.org
  477. CompuServe: Route to above internet address.
  478.